package com.danchuang.consumer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author haitao
 */
@Configuration
public class BasicGetMessageConfig {

    /**
     * 库存主表变动 通过路由key绑定关系
     * @return
     */
    @Bean
    public Binding basicGetMessageBinding() {
        return BindingBuilder.bind(basicGetMessageQueue()).to(basicGetMessageExchange()).with(RabbitConfig.BASIC_ROUTING);
    }

    /**
     * 库存主表变动 队列
     * @return
     */
    @Bean
    public Queue basicGetMessageQueue() {
        return new Queue(RabbitConfig.BASIC_QUEUE);
    }

    /**
     * 库存主表变动 交换机
     * @return
     */
    @Bean
    public DirectExchange basicGetMessageExchange() {
        return new DirectExchange(RabbitConfig.BASIC_EXCHANGE);
    }

}